package com.sgb.packers.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.sgb.net.entity.ListResponse;
import com.sgb.packers.api.PackersNet;
import com.sgb.packers.entity.PressDayCalendarEntity;
import com.sgb.packers.entity.WorkStatisticsEntity;
import com.sgb.packers.entity.WorkTakeEntity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.common.base.TeamViewModel;
import com.swgk.core.interfaces.IView;

import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;

/**
 * @author younghow
 * @date 2021/11/12
 * description:个人记工账本页面的ViewModel
 */
public class RecordWorkAccountBookViewModel extends TeamViewModel<IView> {

    public MutableLiveData<List<PressDayCalendarEntity>> mPressDayLiveData = new MutableLiveData<>();
    public MutableLiveData<ListResponse<List<WorkTakeEntity>>> mStatisticsLiveData = new MutableLiveData<>();

    public RecordWorkAccountBookViewModel(@NonNull @NotNull Application application) {
        super(application);
    }

    public void pressDay(Map<String,Object> map){
        PackersNet.getInstance().getService().pressDay(map).enqueue(new ICallBack<BaseEntity<List<PressDayCalendarEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<PressDayCalendarEntity>> data) {
                mPressDayLiveData.postValue(data.getData());
            }
        });
    }

    public void getWorkStatistics(Map<String,Object> map){
        PackersNet.getInstance().getService().getWorkStatistics(map).enqueue(new ICallBack<BaseEntity<ListResponse<List<WorkStatisticsEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<WorkStatisticsEntity>>> data) {

            }
        });
    }

    public void takeWorkAccount(Map<String, Object> map) {
        mLoading.postValue(SHOW_LODING);
        PackersNet.getInstance().getService().takeWorkAccount(map).enqueue(new ICallBack<BaseEntity<ListResponse<List<WorkTakeEntity>>>>() {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<WorkTakeEntity>>> data) {
                mStatisticsLiveData.postValue(data.getData());
            }
        });
    }
}
